package edu.sjb_beta1.thread;

import edu.sjb_beta1.characters.Mario;
import edu.sjb_beta1.gui.GUI;
import edu.sjb_beta1.map.LogicMapElement;

public class MarioUpUpdaterThread extends Thread {
	private Mario mario;

	public MarioUpUpdaterThread(Mario m) {
		mario = m;
	}
	
	public void run()
	{
		for( int i = 0; i < 10; i++ )
		{
			try
			{
				mario.setLocation(mario.getLocation().x,
						mario.getLocation().y - 32);
				Thread.sleep(30);
			} catch (Exception e)
			{
				e.printStackTrace();
			}
		}
		
		for( int i = 0; i < 10; i++ )
		{
				
		double marioX = GUI.mario.getPositionX();
		double marioY = GUI.mario.getPositionY();
		int X = (int) marioX/32;
		int Y = (int) marioY/32;
		LogicMapElement belowMario = GUI.levelMap.getElementAt(X,Y+2).getLogicElement();	
		if (!belowMario.getName().equals("Brick"))
				{
					try
					{
						mario.setLocation(mario.getLocation().x,
								mario.getLocation().y + 32);
						Thread.sleep(25);
					} catch (Exception e)
					{
						e.printStackTrace();
					}
				}
		}

	}
}